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

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

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

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

j = A("j")
d = B("d")
m = C("m")
e = D("e")
c = C("c")
h = D("h")
g = C("g")
b = D("b")

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

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

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

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

j = A("j")
d = B("d")
m = C("m")
e = D("e")
c = C("c")
h = D("h")
g = C("g")
b = D("b")

j.s = m
d.q = j
d.v = j
d.x = h
m.u = g
m.q = d
e.r = c
c.u = g
c.q = d
h.r = g
g.u = c
g.q = d
b.r = c
assert b.r.u.u.u.q.q.txt == "j"