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

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

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

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

l = A("l")
b = B("b")
e = C("e")
h = D("h")
n = D("n")
c = B("c")
g = B("g")
m = D("m")

l.v = m
l.u = h
b.y = c
e.s = g
e.r = l
e.p = l
e.v = h
h.v = e
h.x = e
h.u = c
n.v = e
n.x = e
n.u = c
c.y = g
g.y = c
m.v = e
m.x = e
m.u = g
assert b.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: D = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
e = C("e")
h = D("h")
n = D("n")
c = B("c")
g = B("g")
m = D("m")

l.v = m
l.u = h
b.y = c
e.s = g
e.r = l
e.p = l
e.v = h
h.v = e
h.x = e
h.u = c
n.v = e
n.x = e
n.u = c
c.y = g
g.y = c
m.v = e
m.x = e
m.u = g
assert b.y.y.y.txt == "c"