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

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

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

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

d = A("d")
n = B("n")
j = C("j")
e = D("e")
g = B("g")
m = C("m")

d.x = j
n.p = j
j.r = m
j.t = g
j.u = d
e.t = g
e.r = m
g.p = m
m.r = j
m.t = n
m.u = d
assert e.t.p.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

d = A("d")
n = B("n")
j = C("j")
e = D("e")
g = B("g")
m = C("m")

d.x = j
n.p = j
j.r = m
j.t = g
j.u = d
e.t = g
e.r = m
g.p = m
m.r = j
m.t = n
m.u = d
assert e.t.p.r.r.txt == "m"