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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
f = C("f")
h = D("h")
n = B("n")
c = B("c")

l.u = h
l.o = h
l.v = f
l.r = f
m.z = l
f.x = h
f.y = h
f.v = l
h.o = f
h.x = f
n.z = l
c.z = l
assert l.r.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: D = None
        self.v: C = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
f = C("f")
h = D("h")
n = B("n")
c = B("c")

l.u = h
l.o = h
l.v = f
l.r = f
m.z = l
f.x = h
f.y = h
f.v = l
h.o = f
h.x = f
n.z = l
c.z = l
assert l.r.y.o.txt == "f"