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

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

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

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

f = A("f")
n = B("n")
g = C("g")
h = D("h")
e = B("e")
d = C("d")
k = A("k")

f.o = e
n.s = h
n.v = h
g.t = f
g.o = k
g.p = h
g.y = d
h.u = k
h.y = k
e.s = h
e.v = h
d.t = k
d.o = k
d.p = h
d.y = g
k.o = e
assert n.s.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
g = C("g")
h = D("h")
e = B("e")
d = C("d")
k = A("k")

f.o = e
n.s = h
n.v = h
g.t = f
g.o = k
g.p = h
g.y = d
h.u = k
h.y = k
e.s = h
e.v = h
d.t = k
d.o = k
d.p = h
d.y = g
k.o = e
assert n.s.u.o.txt == "e"