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

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

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

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

e = A("e")
g = B("g")
m = C("m")
l = D("l")
c = A("c")
d = D("d")
h = B("h")

e.u = m
e.x = g
e.t = g
e.r = h
g.t = e
g.w = c
m.t = l
m.p = l
l.r = c
l.u = m
c.u = m
c.x = h
c.t = h
c.r = g
d.r = e
d.u = m
h.t = c
h.w = e
assert g.t.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: B = None
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

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

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

e = A("e")
g = B("g")
m = C("m")
l = D("l")
c = A("c")
d = D("d")
h = B("h")

e.u = m
e.x = g
e.t = g
e.r = h
g.t = e
g.w = c
m.t = l
m.p = l
l.r = c
l.u = m
c.u = m
c.x = h
c.t = h
c.r = g
d.r = e
d.u = m
h.t = c
h.w = e
assert g.t.u.t.u.txt == "m"