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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: A = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
c = C("c")
j = D("j")
a = D("a")
k = A("k")
m = C("m")
b = C("b")

g.t = l
g.p = b
l.s = j
l.o = k
l.x = c
c.q = g
j.q = m
a.q = b
k.t = l
k.p = b
m.q = g
b.q = g
assert c.q.p.q.p.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: A = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
c = C("c")
j = D("j")
a = D("a")
k = A("k")
m = C("m")
b = C("b")

g.t = l
g.p = b
l.s = j
l.o = k
l.x = c
c.q = g
j.q = m
a.q = b
k.t = l
k.p = b
m.q = g
b.q = g
assert c.q.p.q.p.q.t.txt == "l"