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

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

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

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

e = A("e")
c = B("c")
b = C("b")
g = D("g")
k = A("k")
f = D("f")

e.p = f
e.r = f
c.s = k
c.v = f
c.r = g
b.w = e
g.q = f
g.o = f
g.y = c
g.v = c
k.p = f
k.r = g
f.q = g
f.o = g
f.y = c
f.v = c
assert f.v.r.v.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
b = C("b")
g = D("g")
k = A("k")
f = D("f")

e.p = f
e.r = f
c.s = k
c.v = f
c.r = g
b.w = e
g.q = f
g.o = f
g.y = c
g.v = c
k.p = f
k.r = g
f.q = g
f.o = g
f.y = c
f.v = c
assert f.v.r.v.v.y.v.txt == "f"