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

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

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

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

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

f.o = a
f.r = a
c.v = a
c.y = b
a.y = c
a.w = f
k.y = c
i.y = c
b.v = a
b.y = c
assert a.y.y.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

f.o = a
f.r = a
c.v = a
c.y = b
a.y = c
a.w = f
k.y = c
i.y = c
b.v = a
b.y = c
assert a.y.y.y.v.txt == "a"