class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: A = None
        self.r: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

l = A("l")
n = B("n")
a = C("a")
f = D("f")
g = A("g")
j = B("j")
d = C("d")

l.z = f
l.t = d
n.q = j
a.z = f
a.y = l
a.r = d
f.r = l
g.z = f
g.t = a
j.q = n
d.z = f
d.y = l
d.r = a
assert j.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: A = None
        self.r: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

l = A("l")
n = B("n")
a = C("a")
f = D("f")
g = A("g")
j = B("j")
d = C("d")

l.z = f
l.t = d
n.q = j
a.z = f
a.y = l
a.r = d
f.r = l
g.z = f
g.t = a
j.q = n
d.z = f
d.y = l
d.r = a
assert j.q.q.q.q.q.q.txt == "j"