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

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

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

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

k = A("k")
n = B("n")
b = C("b")
m = D("m")
f = A("f")

k.r = n
n.t = m
b.z = m
b.s = m
b.v = f
m.r = n
m.p = n
m.o = f
f.r = n
assert b.s.o.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
b = C("b")
m = D("m")
f = A("f")

k.r = n
n.t = m
b.z = m
b.s = m
b.v = f
m.r = n
m.p = n
m.o = f
f.r = n
assert b.s.o.r.t.txt == "m"