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

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

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

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

h = A("h")
b = B("b")
d = C("d")
l = D("l")
c = C("c")
j = D("j")
g = A("g")
n = B("n")

h.u = g
b.s = h
b.o = h
b.v = n
b.q = n
d.v = l
d.y = l
d.s = j
l.t = j
c.v = j
c.s = j
c.y = l
j.t = l
g.u = h
n.s = g
n.o = g
n.v = b
n.q = b
assert c.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
d = C("d")
l = D("l")
c = C("c")
j = D("j")
g = A("g")
n = B("n")

h.u = g
b.s = h
b.o = h
b.v = n
b.q = n
d.v = l
d.y = l
d.s = j
l.t = j
c.v = j
c.s = j
c.y = l
j.t = l
g.u = h
n.s = g
n.o = g
n.v = b
n.q = b
assert c.v.t.t.txt == "j"