class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: A = None
        self.x: A = None
        self.q: A = None
        self.txt = txt

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

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

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

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

j.r = d
j.y = d
j.x = d
j.q = d
g.z = d
g.s = d
g.o = c
f.u = g
f.p = c
f.s = c
c.x = j
c.y = j
c.q = g
c.u = g
d.r = j
d.y = j
d.x = j
d.q = j
assert g.o.y.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: A = None
        self.x: A = None
        self.q: A = None
        self.txt = txt

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

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

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

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

j.r = d
j.y = d
j.x = d
j.q = d
g.z = d
g.s = d
g.o = c
f.u = g
f.p = c
f.s = c
c.x = j
c.y = j
c.q = g
c.u = g
d.r = j
d.y = j
d.x = j
d.q = j
assert g.o.y.x.r.txt == "j"