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

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: A = None
        self.z: C = None
        self.v: C = None
        self.txt = txt

b = A("b")
g = B("g")
e = C("e")
a = D("a")

b.o = e
b.s = e
b.y = g
b.r = g
g.w = b
g.t = b
g.r = a
e.o = b
e.p = g
e.u = a
a.u = g
a.y = b
a.z = e
a.v = e
assert a.z.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: B = None
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: A = None
        self.z: C = None
        self.v: C = None
        self.txt = txt

b = A("b")
g = B("g")
e = C("e")
a = D("a")

b.o = e
b.s = e
b.y = g
b.r = g
g.w = b
g.t = b
g.r = a
e.o = b
e.p = g
e.u = a
a.u = g
a.y = b
a.z = e
a.v = e
assert a.z.p.r.txt == "a"