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

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

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

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

b = A("b")
l = B("l")
m = C("m")
n = D("n")
e = D("e")
g = B("g")

b.w = l
l.p = g
l.u = g
l.z = b
m.t = b
m.w = b
m.q = n
n.q = b
n.v = m
e.q = b
e.v = m
g.p = l
g.u = l
g.z = b
assert l.u.u.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
m = C("m")
n = D("n")
e = D("e")
g = B("g")

b.w = l
l.p = g
l.u = g
l.z = b
m.t = b
m.w = b
m.q = n
n.q = b
n.v = m
e.q = b
e.v = m
g.p = l
g.u = l
g.z = b
assert l.u.u.p.z.txt == "b"