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

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

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

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

a = A("a")
l = B("l")
b = C("b")
d = D("d")
i = D("i")
k = D("k")
e = A("e")
f = B("f")
g = B("g")

a.y = e
a.q = b
l.p = i
l.o = g
b.w = e
d.u = e
i.u = a
k.u = e
e.y = a
e.q = b
f.p = i
f.o = g
g.p = i
g.o = f
assert g.p.u.y.y.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: C = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
b = C("b")
d = D("d")
i = D("i")
k = D("k")
e = A("e")
f = B("f")
g = B("g")

a.y = e
a.q = b
l.p = i
l.o = g
b.w = e
d.u = e
i.u = a
k.u = e
e.y = a
e.q = b
f.p = i
f.o = g
g.p = i
g.o = f
assert g.p.u.y.y.q.w.txt == "e"