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

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

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

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

l = A("l")
c = B("c")
k = C("k")
d = D("d")
m = D("m")
f = B("f")

l.o = k
l.w = d
c.r = k
c.q = k
c.s = k
c.p = l
k.s = m
d.v = m
d.o = c
d.u = k
d.s = k
m.v = d
m.o = f
m.u = k
m.s = k
f.r = k
f.q = k
f.s = k
f.p = l
assert d.v.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: D = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
k = C("k")
d = D("d")
m = D("m")
f = B("f")

l.o = k
l.w = d
c.r = k
c.q = k
c.s = k
c.p = l
k.s = m
d.v = m
d.o = c
d.u = k
d.s = k
m.v = d
m.o = f
m.u = k
m.s = k
f.r = k
f.q = k
f.s = k
f.p = l
assert d.v.o.p.txt == "l"