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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.p: D = None
        self.v: C = None
        self.txt = txt

l = A("l")
d = B("d")
g = C("g")
j = D("j")
m = C("m")
b = D("b")

l.u = m
d.q = j
d.s = j
d.t = j
g.t = m
g.o = l
g.r = l
j.u = g
j.v = g
j.x = m
j.p = b
m.t = g
m.o = l
m.r = l
b.u = g
b.x = m
b.v = m
b.p = j
assert b.u.t.o.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.p: D = None
        self.v: C = None
        self.txt = txt

l = A("l")
d = B("d")
g = C("g")
j = D("j")
m = C("m")
b = D("b")

l.u = m
d.q = j
d.s = j
d.t = j
g.t = m
g.o = l
g.r = l
j.u = g
j.v = g
j.x = m
j.p = b
m.t = g
m.o = l
m.r = l
b.u = g
b.x = m
b.v = m
b.p = j
assert b.u.t.o.u.r.u.txt == "m"