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

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

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

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

c = A("c")
b = B("b")
f = C("f")
m = D("m")
i = A("i")

c.r = b
c.z = b
b.o = f
f.q = m
f.v = m
f.t = c
f.r = b
m.q = b
m.y = c
m.w = f
i.r = b
i.z = b
assert c.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
f = C("f")
m = D("m")
i = A("i")

c.r = b
c.z = b
b.o = f
f.q = m
f.v = m
f.t = c
f.r = b
m.q = b
m.y = c
m.w = f
i.r = b
i.z = b
assert c.r.o.r.txt == "b"