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

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

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

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

f = A("f")
n = B("n")
l = C("l")
b = D("b")
c = C("c")
d = A("d")

f.r = n
f.p = n
f.v = l
n.u = l
l.v = c
b.w = l
b.o = f
b.t = f
c.v = l
d.r = n
d.p = n
d.v = l
assert c.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: C = None
        self.p: B = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
l = C("l")
b = D("b")
c = C("c")
d = A("d")

f.r = n
f.p = n
f.v = l
n.u = l
l.v = c
b.w = l
b.o = f
b.t = f
c.v = l
d.r = n
d.p = n
d.v = l
assert c.v.v.v.v.txt == "c"