class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: B = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

f = A("f")
m = B("m")
g = C("g")
j = D("j")
l = E("l")
b = D("b")
h = B("h")

f.o = m
f.t = l
m.v = b
g.o = f
g.w = h
g.y = l
j.q = h
l.t = g
b.q = h
h.v = j
assert h.v.q.v.q.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: B = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

f = A("f")
m = B("m")
g = C("g")
j = D("j")
l = E("l")
b = D("b")
h = B("h")

f.o = m
f.t = l
m.v = b
g.o = f
g.w = h
g.y = l
j.q = h
l.t = g
b.q = h
h.v = j
assert h.v.q.v.q.v.q.v.txt == "j"