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

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

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

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

d = A("d")
j = B("j")
g = C("g")
c = D("c")

d.o = c
d.s = j
j.u = c
j.x = d
g.z = d
g.v = c
g.t = c
g.p = c
c.t = d
c.r = g
assert g.z.s.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
g = C("g")
c = D("c")

d.o = c
d.s = j
j.u = c
j.x = d
g.z = d
g.v = c
g.t = c
g.p = c
c.t = d
c.r = g
assert g.z.s.u.r.txt == "g"