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

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

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

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

n = A("n")
i = B("i")
a = C("a")
j = D("j")
h = C("h")
k = C("k")
g = B("g")

n.v = i
i.y = g
i.u = h
i.v = k
a.r = n
a.o = n
a.y = h
j.p = i
h.r = n
h.o = n
h.y = k
k.r = n
k.o = n
k.y = a
g.y = i
g.u = a
g.v = a
assert a.y.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
a = C("a")
j = D("j")
h = C("h")
k = C("k")
g = B("g")

n.v = i
i.y = g
i.u = h
i.v = k
a.r = n
a.o = n
a.y = h
j.p = i
h.r = n
h.o = n
h.y = k
k.r = n
k.o = n
k.y = a
g.y = i
g.u = a
g.v = a
assert a.y.r.v.txt == "i"