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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.r: B = None
        self.t: D = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
k = C("k")
j = D("j")
b = A("b")
g = D("g")
c = B("c")
h = C("h")

e.x = j
l.q = c
l.r = c
l.x = h
l.t = j
k.p = h
k.t = c
j.p = e
j.x = g
j.t = h
b.x = j
g.p = b
g.x = j
g.t = k
c.q = l
c.r = l
c.x = h
c.t = j
h.p = k
h.t = l
assert g.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.r: B = None
        self.t: D = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
k = C("k")
j = D("j")
b = A("b")
g = D("g")
c = B("c")
h = C("h")

e.x = j
l.q = c
l.r = c
l.x = h
l.t = j
k.p = h
k.t = c
j.p = e
j.x = g
j.t = h
b.x = j
g.p = b
g.x = j
g.t = k
c.q = l
c.r = l
c.x = h
c.t = j
h.p = k
h.t = l
assert g.x.t.t.txt == "l"