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

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

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

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

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

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

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

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

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

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

f.o = l
f.v = b
f.p = k
j.v = c
m.y = f
m.p = j
m.r = c
k.u = m
b.y = l
b.p = j
b.r = c
c.u = b
l.o = f
l.v = m
l.p = c
assert c.u.p.v.u.txt == "b"