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

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

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

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

a = A("a")
c = B("c")
n = C("n")
f = D("f")
i = A("i")
e = D("e")
l = B("l")
g = A("g")
h = C("h")
j = A("j")

a.x = n
c.t = j
n.r = g
n.s = h
n.y = a
n.t = f
f.v = n
i.x = n
e.v = h
l.t = a
g.x = n
h.r = a
h.s = n
h.y = g
h.t = f
j.x = h
assert n.s.y.x.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

a = A("a")
c = B("c")
n = C("n")
f = D("f")
i = A("i")
e = D("e")
l = B("l")
g = A("g")
h = C("h")
j = A("j")

a.x = n
c.t = j
n.r = g
n.s = h
n.y = a
n.t = f
f.v = n
i.x = n
e.v = h
l.t = a
g.x = n
h.r = a
h.s = n
h.y = g
h.t = f
j.x = h
assert n.s.y.x.s.y.txt == "g"