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

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

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

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

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

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

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

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

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

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

h.q = j
h.v = j
h.o = c
h.t = i
c.r = h
a.y = n
a.r = h
i.y = n
i.u = n
i.r = h
i.q = g
g.y = n
g.r = h
j.y = i
j.r = h
n.y = i
n.u = i
n.r = h
n.q = g
assert g.r.t.q.y.txt == "n"