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

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

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

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

h = A("h")
e = B("e")
a = C("a")
l = D("l")
f = D("f")
d = B("d")
c = A("c")

h.u = c
h.v = c
e.x = f
e.v = f
a.y = f
a.z = h
l.r = e
l.o = h
f.r = d
f.o = c
d.x = l
d.v = f
c.u = h
c.v = h
assert e.v.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: A = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
a = C("a")
l = D("l")
f = D("f")
d = B("d")
c = A("c")

h.u = c
h.v = c
e.x = f
e.v = f
a.y = f
a.z = h
l.r = e
l.o = h
f.r = d
f.o = c
d.x = l
d.v = f
c.u = h
c.v = h
assert e.v.o.u.txt == "h"