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

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

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

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

g = A("g")
b = B("b")
d = C("d")
e = D("e")
a = A("a")

g.w = b
g.y = a
g.q = d
b.t = d
b.y = e
d.v = e
d.t = e
d.u = g
d.w = g
e.u = g
e.o = b
a.w = b
a.y = g
a.q = d
assert b.t.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: A = None
        self.q: C = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
d = C("d")
e = D("e")
a = A("a")

g.w = b
g.y = a
g.q = d
b.t = d
b.y = e
d.v = e
d.t = e
d.u = g
d.w = g
e.u = g
e.o = b
a.w = b
a.y = g
a.q = d
assert b.t.t.o.txt == "b"